using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Backend.JYD.AModel.Models.Mapping
{
    public class IntentEntryInfoMap : EntityTypeConfiguration<IntentEntryInfo>
    {
        public IntentEntryInfoMap()
        {
            // Primary Key
            this.HasKey(t => t.IntentId);

            // Properties
            this.Property(t => t.CustNo)
                .HasMaxLength(20);

            this.Property(t => t.CustName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.PaperType)
                .HasMaxLength(5);

            this.Property(t => t.PaperNo)
                .HasMaxLength(50);

            this.Property(t => t.Phone)
                .HasMaxLength(20);

            this.Property(t => t.Purpose)
                .HasMaxLength(100);

            this.Property(t => t.Remark)
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("IntentEntryInfo");
            this.Property(t => t.IntentId).HasColumnName("IntentId");
            this.Property(t => t.CustNo).HasColumnName("CustNo");
            this.Property(t => t.TaskId).HasColumnName("TaskId");
            this.Property(t => t.TaskDetailId).HasColumnName("TaskDetailId");
            this.Property(t => t.CustName).HasColumnName("CustName");
            this.Property(t => t.PaperType).HasColumnName("PaperType");
            this.Property(t => t.PaperNo).HasColumnName("PaperNo");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.ChanelType).HasColumnName("ChanelType");
            this.Property(t => t.LoanMoney).HasColumnName("LoanMoney");
            this.Property(t => t.Term).HasColumnName("Term");
            this.Property(t => t.Rate).HasColumnName("Rate");
            this.Property(t => t.Purpose).HasColumnName("Purpose");
            this.Property(t => t.RepaymentType).HasColumnName("RepaymentType");
            this.Property(t => t.Guarantee).HasColumnName("Guarantee");
            this.Property(t => t.Remark).HasColumnName("Remark");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
            this.Property(t => t.UpdateTime).HasColumnName("UpdateTime");
            this.Property(t => t.OpId).HasColumnName("OpId");

            // Relationships
            this.HasOptional(t => t.CustBase)
                .WithMany(t => t.IntentEntryInfoes)
                .HasForeignKey(d => d.CustNo);

        }
    }
}
